package secretary;

import java.sql.SQLException;

import basic.ClientConsole;

import com.sun.rowset.CachedRowSetImpl;

import flexibility.userData;

public class getClasses {

	private setSemesterEditable sse;
	private int semester;
	public CachedRowSetImpl getClasses(ClientConsole secretaryConnection,
			CachedRowSetImpl crs, userData secretaryData, int semesterCode) {
		/*
		 * this will get all the class table details in order to create the gui
		 * for it
		 */
		switch(semesterCode){
		case 1:
			secretaryData.deleteAll();
			secretaryData.addData(18);
			secretaryData.addData(1);
			
			secretaryConnection.acceptMsg(secretaryData);
			crs = secretaryConnection.getResults();
			try {
				crs.next();
				 semester = Integer.parseInt(crs.getString(1));
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			secretaryData.deleteAll();
			secretaryData.addData(12);
			secretaryData.addData(1);
			secretaryData.addData(semester);
			secretaryConnection.acceptMsg(secretaryData);
			crs = secretaryConnection.getResults();
			break;
		case 0:
			secretaryData.deleteAll();
			secretaryData.addData(17);
			secretaryData.addData(1);
			
			secretaryConnection.acceptMsg(secretaryData);
			crs = secretaryConnection.getResults();
			try {
				crs.next();
				 semester = Integer.parseInt(crs.getString(1));
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			secretaryData.deleteAll();
			secretaryData.addData(81);
			secretaryData.addData(1);
			secretaryData.addData(semester);
			secretaryConnection.acceptMsg(secretaryData);
			crs = secretaryConnection.getResults();
			break;
			
		}
			
		
		return crs;

	}
}
